<template>
	<view class="LiveInteraction">
		<view :style="{'height': `${statusBarHeight}px`, 'background-color': '#060143'}"></view>
		<uni-nav-bar backgroundColor="#060143;" color="#FFF" :title="$t('language.LiveInteraction')" @clickLeft="goBack" left-icon="left"
			:border="false" />
		<view class="logo">
			<image class="logo-ic" src="@/static/logo.png" alt="" />
			<view class="lang-wrap" @click="changeLanguage">
				<image src="../../static/100.png" mode=""></image>
				<text>{{$t('locale.lang')}}</text>
			</view>
		</view>
		<view class="linkLive">
			<view class="linkGroup" @click="toLink(1)" v-if="tou_start == 1">
				<image :src="`${baseUrl}/static/img/link1.png`" />
				<view class="title">
					<image :src="`${baseUrl}/static/img/linkicon1.png`" />
					{{$t('language.live5')}}
				</view>
			</view>
			<view class="linkGroup" @click="toLink(2)" v-if="hu_start == 1">
				<image :src="`${baseUrl}/static/img/link2.png`" />
				<view class="title">
					<image :src="`${baseUrl}/static/img/linkicon2.png`" />
					{{$t('language.live6')}}
				</view>
			</view>
			<view class="linkGroup" @click="toLink(3)" v-if="wen_start == 1">
				<image :src="`${baseUrl}/static/img/link3.png`" />
				<view class="title">
					<image :src="`${baseUrl}/static/img/linkicon3.png`" />
					{{$t('language.live7')}}
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		HTTP_REQUEST_URL
	} from '@/config/app';
	import uniIcons from "@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
	import {
		evenCan
	} from "@/api/user";
	let timer = null
	export default {
		name: 'LiveInteraction',
		components: {
			uniIcons
		},
		data() {
			return {
				baseUrl: HTTP_REQUEST_URL,
				statusBarHeight: 44,
				evenId: '',
				tou_start: '',
				hu_start: '',
				wen_start: '',
				safeTop: ''
			}
		},
		onLoad(o) {
			const safe = uni.getSystemInfoSync()
			this.safeTop = safe.safeArea.top
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
			let evenId = o.evenId;
			this.evenId = evenId;
			this.getConfig();
		},
		created() {},
		methods: {
			getConfig() {
				evenCan({
					event_id: this.evenId
				}).then(
					response => {
						if (response.code == 200) {
							this.tou_start = response.data.tou_start
							this.hu_start = response.data.hu_start
							this.wen_start = response.data.wen_start
						} else {
							console.log(response);
						}
					},
					err => {
						console.log(err)
					}
				);
			},
			toLink(index) {
				if (index == 1) {
					uni.navigateTo({
						url: '/pages/LiveInteraction/VotingList?evenId=' + this.evenId
					})
				} else if (index == 2) {
					uni.navigateTo({
						url: '/pages/LiveInteraction/CloudList?evenId=' + this.evenId
					})
				} else if (index == 3) {
					uni.navigateTo({
						url: '/pages/LiveInteraction/QuestionList?evenId=' + this.evenId
					})
				}
			},
			goBack() {
				uni.redirectTo({
					url: '/pages/indexBox/index?istype=1' + '&evenId=' + this.evenId
				})	
				// uni.navigateBack()
			},
			changeLanguage() {
				if (this.$i18n.locale == 'zh') {
					this.$i18n.locale = 'en';
					uni.setStorageSync('locale', 'en')
				} else {
					this.$i18n.locale = 'zh';
					uni.setStorageSync('locale', 'zh')
				}
			}
		}
	}
</script>
<style lang="scss">
	page {
		background: #050033;
	}

	.logo {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20upx 30upx;
		background-color: #060143;

		.logo-ic {
			width: 78upx;
			height: 64upx;
		}

		.lang-wrap {
			display: flex;
			align-items: center;
			color: #fff;
			font-size: 24upx;

			image {
				width: 30upx;
				height: 30upx;
				margin-right: 12upx;
			}
		}
	}

	.LiveInteraction {
		width: 100%;
		min-height: 100vh;
		box-sizing: border-box;
		/* padding-top: 0.5rem; */
		background: #050033;
	}

	.headerChangeLanguage {
		height: 100upx;
		background: #fff;
		padding: 0 30upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-shadow: 0 2upx 4upx #ccc;
		width: 100%;
		box-sizing: border-box;
	}

	.logo image {
		width: 178upx;
		height: 30upx;
	}


	.language {
		flex-shrink: 0;
	}

	.langeageZh {
		height: 30upx;
		width: 86upx;
		background: url($image-base-url + '/static/img/EN-17.png') no-repeat;
		background-size: 86upx 30upx;
	}

	.langeageEn {
		height: 30upx;
		width: 86upx;
		background: url($image-base-url + '/static/img/CH-17.png') no-repeat;
		background-size: 86upx 30upx;
	}

	.linkLive {
		padding: 30upx;
	}

	.linkGroup {
		margin-bottom: 48upx;
	}

	.linkGroup>image {
		display: block;
		width: 100%;
		height: 244upx;
		object-fit: cover;
		position: relative;
		margin-bottom: 30upx;
		box-shadow: 0 0 10upx #ccc;
		border-radius: 20upx;
	}

	.linkGroup .title {
		width: 100%;
		display: flex;
		align-items: center;
		color: #fff;
		font-size: 36upx;
	}

	.linkGroup .title image {
		width: 36upx;
		height: 42upx;
		margin-right: 20upx;
		object-fit: contain;
	}
</style>